#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

#define PRINT( x ) printf( # x ": %d\n", x )
#define MAXBUF 1024 * 4

void static pr_env( void );
void static pr_env( const char * );

int main( int argc, char *argv[] )
{
	/*
	   // ssize_t readlink(const char *path, char *buf, size_t bufsiz);
	   char buf[MAXBUF];
	   memset( buf, 0, MAXBUF);
	   char * file = "/home/liubin/lb/small/aaaa";
	   if( argc > 1 )
		file = argv[1];

	   //int ret = readlink( "/home/liubin/project/tkbend/trunk/crawler/script", buf, MAXBUF);
	   int ret = readlink( file, buf, MAXBUF);
	   PRINT(ret);
	   if( ret != 0 )
		PRINT(errno);
	   buf[MAXBUF-1] = '\0';
	   printf("readlink: %s\n", buf);
	   return 0;
	 */

	pr_env( "PATH" );
	pr_env( "PATH" );
	setenv( "PATH", "/usr/bin:/bin", 1 );
	pr_env( "PATH" );
	pr_env( "dddd" );
	return 0;
}

extern char **environ;

void static pr_env( void )
{
	for( char **env = environ; *env != NULL; env++ ) {
		printf( "%s\n", *env );
	}
	return;
}

void static pr_env( const char *name )
{
	char *p = getenv( name );

	printf( "POINTER: %x\n", (unsigned int)p );
	if( NULL != p ) {
		printf( "VALUE: %s\n", p );
	}
	return;
}
